<?php
/**
 * Created by JetBrains PhpStorm.
 * User: cgp
 * Date: 13-4-6
 * Time: 下午12:32
 *
 * 产品操作
 */
include('../common/autoload.php');
include '../module/link_product/function.php';
include '../module/link_product/chkPackage_dt.php';
include '../class/Member.php';
include '../common/errBack.php';
use \pft\Prod\Product;
use \pft\Member\MemberAccount;
use pft\Prod\Ticket;
$ptypeList = array('A','B','C','D','F');
$action  = $_REQUEST['action'];
$applyid = $_SESSION['memberID'];
$prod = new \pft\Prod\ProductDev($GLOBALS['le']);
$mem = new MemberAccount($GLOBALS['le']);
$soap = SoapInit::GetSoapInside();
$member = new Member($soap,$applyid);
$applydid = $_SESSION['memberID'];
//print_r($GLOBALS['le']->fetch_assoc());
switch($action) {
    case 'CreateNewProduct' :
        $ptype = !in_array($_POST['ptype'],$ptypeList) ? exit('{"res":0,"msg":"类型不对！"}'):$_POST['ptype'];
        $sData['title'] = p_match($_POST['mainTitle']) ?
            exit('{"res":0,"msg":"景区名称含有非法字符"}') : safetxt($_POST['mainTitle']);
        if(mb_strlen($sData['title'],'utf8')>20){
            exit('{"res":0,"msg":"景区名称不能超过 30 个字符"}');
        }
        $sData['apply_did'] = abs($_POST['applydid']);
        $byadmin = $_POST['admin']=='16u' ? true : false;
        $parent_id = 0;
        if(ctype_digit($_POST['parent_id']) && $_POST['parent_id']>0) {
            $parent_id = $_POST['parent_id'];
        }
        $tel = trim($_POST['mainPhoneNum']);
        if(strlen($tel)) {
            $sData['tel'] = isphone($tel)||ismobile($tel) ? $tel
                : exit('{"res":0,"msg":"联系电话格式不正确"}');
        }
        if(!empty($_POST['smsMsgPhone'])) {
            $sData['fax'] = ismobile($_POST['smsMsgPhone']) ? $_POST['smsMsgPhone']
                : exit('{"res":0,"msg":"手机号码格式不正确"}');
        }
        if(!empty($_POST['topic'])) {
            $topic = implode(',',$_POST['topic']);
            $sData['topic'] = addslashes(strip_tags($topic));
        }
        $sData['jtype'] = safetxt($_POST['jtype']);
        $sData['runtime'] = safetxt($_POST['runtime']);//营业时间OR出发时间
        //套票产品属性，非空为套票 格式:二维数组json array(array('pid'=>301,'num'=>1),
        //array('pid'=>302,'num'=>3))
        if(isset($_POST['package_attr'])) {
            $sData['attribute'] = trim($_POST['package_attr']);
        }
        if(isset($_POST['d_province'])) {
            $sData['area']  = abs($_POST['d_province']) .'|'
                . abs($_POST['d_city']) .'|' .abs($_POST['d_zone']);
        }
        if(isset($_POST['delaytime'])) {
            if ($_POST['delaytime']==1 && (trim($_POST['vtimehour']) || trim($_POST['vtimeminu']))){
            $sData['delaytime']  = abs($_POST['vtimehour']) .'|'
                . abs($_POST['vtimeminu']);
            }
            else $sData['delaytime']='';
        }        
        if(isset($_POST['mainAddress'])) {
            $sData['address'] = p_match($_POST['mainAddress'])
                ? exit('{"res":0,"msg":"地址含有非法字符"}')
                : safetxt($_POST['mainAddress']);
        } elseif(isset($_POST['start_place'])) {
            //线路产品将出发地、目的地存在runtime字段
            $sData['runtime'] = safetxt($_POST['start_place']) . '|' . safetxt($_POST['end_place']);
        }
        $sData['p_type'] = $ptype;
        //exit;
        $sData['jdjj'] = safetxt($_POST['infoIntro']);
        if(strlen($_POST['detailInfo'])>0) {
            $sData['bhjq'] = safehtml($_POST['detailInfo']);
            if(fliter_words($sData['bhjq'])) {
                exit('{"res":0,"msg":"'.$FieldList[$ptype]['bhjq']['t'].'含有非法字符！添加失败！"}');
            }
        }

        if(!empty($_POST['buyTips']) ) {
            if(fliter_words($_POST['buyTips'])) {
                exit('{"res":0,"msg":"'.$FieldList[$ptype]['jqts']['t'].'含有非法字符！添加失败！"}');
            }
            $sData['jqts'] = safetxt($_POST['buyTips']);
        }
        if(!empty($_POST['trafficInfo'])) {
            if(fliter_words($_POST['trafficInfo'])) {
                exit('{"res":0,"msg":"'.$FieldList[$ptype]['jtzn']['t'].'含有非法字符,添加失败！"}');
            }
            $sData['jtzn'] =safetxt($_POST['trafficInfo']);
        }
        if(empty($_POST['thumb_img'])) {
            exit('{"res":0,"msg":"请上传产品缩略图！"}');
        }
//    elseif(fliter_words($_POST['thumb_img'])) {
//        exit('{"res":0,"msg":"缩略图地址不正确"}');
//    }
        else {
            $sData['imgpath'] = $_POST['thumb_img'];
        }
        if( !empty($_POST['lastid']) && abs($_POST['lastid'])>0 ) {
            $lastid = abs($_POST['lastid']);
            $res = $prod->UpdateScenery($sData, $lastid, $sData['delaytime']);
        }
        else {
            $now = date('Y-m-d H:i:s');
            if($byadmin ) {
                $sData['passtime'] = $now;
                $sData['status'] = 1;
            }
            $sData['addtime'] = $now;
            $res = $prod->AddProduct($sData, $mem, $parent_id, $sData['delaytime']);
        }
        if($byadmin) {
            $res['byadmin'] = 1;
        }
        echo json_encode($res);
        break;
    case 'CreateNewTicket':
        $lid = abs($_POST['lastid']) >0 ? abs($_POST['lastid']) :
            exit('{"res":0,"msg":"请先保存景区信息后再保存门票信息！"}');
        $applyid = abs($_POST['did']);
        $tid = $_POST['tid']>0 ? abs($_POST['tid']): 0;//门票表主键，更新用
        $ticketObj = new TicketCSync();
        //print_r($ticketObj);exit;
        $res = $ticketObj->AddTicket($lid,$applyid,$tid, $prod);

        //echo json_encode($res);
        if($res['errcode']!==1000) {
            echo json_encode($res);
            exit;
        }
        if(isset($_POST['ticket']) && is_array($_POST['ticket'])) {
            //echo $res['pid'];exit;
            //echo json_encode($_POST['ticket']);exit;
            $cre_res = array();
            $upt_res = array();
            $cre_inc = 0;
            $upt_inc = 0;
            $pft_rflex_id = abs($_POST['pft_rflex_id']);
            $soap2 = $pft_rflex_id >0 ? SoapInit::GetSoapFX() : null;
            $package = getMainId($_REQUEST['pid'], 2);
            $Price = new Price(-1);
            $hasMd = array();

            //TODO::同步处理,更新后会回传sync_id和sync_status  ---cgp
            $sync_id     = $res['sync_id'];
            $sync_status = $res['sync_status'];

            foreach($_POST['ticket'] as $key=>$post) {
                if($post['pl'] < $post['pg']) {
                    echo  '{"errcode":1007,"msg":"零售价不能小于供货价！"}';
                    exit;
                }
                if($key<=0) {
                    //create
                    $cr = $ticketObj->AddPrice($res['pid'], $post,0, $soap,
                        $pft_rflex_id, $soap2,$res['sync_id'], $res['sync_status']);
                    //echo $cr;
                    $cr == 100 ? $cre_inc += 1 : $cre_res[] = $SoapRequestChk[$cr].$cr;
                }
                elseif($key>0) {
                    if(count($package)){
                        // 找出子票的时间段日历价格
                        $xml = $Price->GetDynamicPrice('', 1, $post['bt'], $post['et'], 0, 0, $_REQUEST['pid']);
                        $sx = simplexml_load_string($xml);
                        // 找出套票的时间段日历价格(每个套票一个数组)
                        $packs = array();
                        $nums = array();
                        foreach($package as $pv => $tsa){// 会找出重复
                            $tmpXml = $Price->GetDynamicPrice('', 1, $post['bt'], $post['et'], 0, 0, $pv);
                            $tmpSx = simplexml_load_string($tmpXml);
                            if(empty($tmpSx)) continue;
                            $packs[$pv]=$tmpSx;
                            $tp = explode('|',$tsa);
                            $nums[$pv] = $tp[1] ;
                        }
                    }
                    //update

                    $ur = $ticketObj->AddPrice($res['pid'], $post,$key, $soap,
                        $pft_rflex_id, $soap2, $res['sync_id'], $res['sync_status']);

                    if($ur == 100){    // 修改成功后找到该子票打包的套票
                        $area = true;
                        if((strtotime($post['et']) - strtotime($post['bt']))==0){// 更改子票时间段时，时间段内如果有单独配置，配置是不生效的
                            $area = false;
                        }
                        // 处理
                        if(count($sx->Rec)){
                            foreach($sx->Rec as $val){
                                if((strtotime((string)$val->UUstart_date) - strtotime((string)$val->UUend_date))==0 && $area)continue;// 配置一天的
                                // 子票原售价
                                $sPs = (string)$val->UUs_price ? (string)$val->UUs_price:(string)$val->UUn_price;// 供货价
                                $sPl = (string)$val->UUl_price;// 零售价
                                $diffPs = $post['pg'] - $sPs/100;
                                $diffPl = $post['pl'] - $sPl/100;
                                
                                // 每个套票
                                foreach($packs as $pv){
                                    // 每个时间数组
                                    foreach($pv as $dk => $de){
                                        //     配置一天的
                                        if((strtotime((string)$de->UUstart_date) - strtotime((string)$de->UUend_date))==0 && $area)continue;
                                        if(((string)$val->UUstart_date==(string)$de->UUstart_date)&&((string)$val->UUend_date==(string)$de->UUend_date) || ((string)$de->UUstart_date>=(string)$val->UUstart_date)&&((string)$val->UUend_date>=(string)$de->UUend_date)){// 时间段相同就设置价格或者区间内
                                        
                                            if($diffPs>0){// 增加
                                                // 套票原日期价格
                                                $packPris = (string)$de->UUs_price ? (string)$de->UUs_price:(string)$de->UUn_price;// 供货价
                                                $packPril = (string)$de->UUl_price;// 零售价
                                                $packPris = $packPris + $diffPs*100*$nums[(string)$de->UUpid];
                                                $packPril = $packPril + $diffPl*100*$nums[(string)$de->UUpid];;
                                                
                                                $hasMd[] = (string)$de->UUpid;// 有修改的后面通知供应商
                                                // 间隔区间内则应该是没有记录的
                                                // $rid = (((string)$val->UUstart_date >= (string)$de->UUstart_date)&&((string)$val->UUend_date<=(string)$de->UUend_date)) ? 0:(string)$de->UUid;
                                                $rid = (string)$de->UUid;
                                                // echo "DynamicPriceStatic({$de->UUpid}, {$de->UUstart_date},{$de->UUend_date}, $packPris, $packPril,{$de->UUptype},{$rid}, {$de->UUmemo}, {$de->UUweekdays}, , {$de->UUstorage})";
                                                // print_r(
                                                Price::DynamicPriceStatic((string)$de->UUpid, (string)$de->UUstart_date,(string)$de->UUend_date, $packPris, $packPril, (string)$de->UUptype,$rid, (string)$de->UUmemo, (string)$de->UUweekdays, $soap, (string)$de->UUstorage);
                                                // );
                                            }
                                        }

                                    }
                                }
                            }
                        }
                    }
                    $ur == 100 ? $upt_inc +=1 : $upt_res[] = $SoapRequestChk[$ur].$ur;
                }
            }//EOF FOREACH
            
            if(count($hasMd)){// 发送平台信息通知
                include_once '../class/notice.class.php';
                include_once '../class/MemberAccount.class.php';
                $notice = new pft\notice();
                $ids = implode(',',$hasMd).','.abs($_REQUEST['pid']);
                $sql="SELECT p_name,apply_did,id FROM uu_products WHERE id IN ($ids)";
                $GLOBALS['le']->query($sql);
                $pinfo = array();
                while($row=$GLOBALS['le']->fetch_assoc()){
                    $pinfo[$row['id']]=$row;
                }
                foreach($pinfo as $k => $v){
                    if($k==abs($_REQUEST['pid'])) continue;
                    $packName = $v['p_name'];
                    $sonName = $pinfo[abs($_REQUEST['pid'])]['p_name'];
                    $msg = "您的套票产品【{$packName}】由于子票【{$sonName}】价格上调，系统自动上调套票价格，如果不想调整，请自行设置";
                    // echo "AddNotice('套票价格上调', $msg, 1, 9999, 1, 0, '', '',MemberAccount(le, {$v['apply_did']},),    {$v['apply_did']})";

                    $notice->AddNotice('套票价格上调', $msg, 1, 9999, 1, 0, '', '',
                        new \pft\Member\MemberAccount($GLOBALS['le'], $v['apply_did'], $s),
                        $v['apply_did']
                    );
                }
            }
            
            $cr_fail = count($cre_res);
            $ut_fail = count($upt_res);
            $pri_msg = "<br/>添加价格配置成功<span class='red'>{$cre_inc}</span>条，"
                ."失败<span class='red'>{$cr_fail}</span>条;<br/>";
            $pri_msg .= $cr_fail>0 ? "失败原因分别为:".implode(';',$cre_res).'<br/>':'';
            $pri_msg .= "更新价格配置<span class='red'>{$upt_inc}</span>条，".
                "失败<span class='red'>{$ut_fail}</span>条;<br/>";
            $pri_msg .= $ut_fail >0 ? "失败原因分别为:".implode(';',$upt_res).'<br/>':'';
            $res['msg'] .= $pri_msg;
        }
        //print_r($res);
        // 检测是否有套票，有套票并且各关联子票有冲突，下架套票
        $msg = chkPackage($res['pid'],$GLOBALS['le']);
        
        if(count($msg)){
            foreach($msg as $k=>$v){
                $prod->SetSceneryState(substr($k,2),2,'系统下架');
            }
        }
        // 重新生成静态文件
        file_get_contents("http://www.12301.cc/module/link_product/save_link_products.php?token=cgp");
        echo json_encode($res);
        break;
    //产品状态设置
    case 'SetSceneryState':
        $id = $_POST['lid'];//数组或数字
        $state = abs($_POST['state']);
        $operid = isset($_SESSION['memberID'])? 
        $_SESSION['memberID']: exit('{"msg":"您还未登录或登录超时，请刷新页面后重新登录"}') ;
        $res = $prod->SetSceneryState($id,$state,'分销商ID='.$operid);
        // 以下检测是否有打包的套票，有则一起下架
        if($state == 2 || $state == 3 ){
            $sql="SELECT p.id FROM uu_products p LEFT JOIN uu_jq_ticket t ON p.id=t.pid WHERE t.landid=$id AND p.p_status<6";
            $GLOBALS['le']->query($sql);
            $package = array();
            while($row=$GLOBALS['le']->fetch_assoc()){
                $package = array_merge($package,getMainId($row['id']));// 获取该门票被打包的景区ID
            }
            $package = array_unique($package);
            if(count($package)){
                $sql="SELECT id FROM uu_land WHERE status=1 AND id IN (".implode(',',$package).")";
                $package = array();
                $GLOBALS['le']->query($sql);
                while($row=$GLOBALS['le']->fetch_assoc()){
                    $prod->SetSceneryState($row['id'],2,'系统下架');
                    $stateMsg['S:'.$row['id']] = array(
                        'timer'=>date('Y年m月d日 H:i:s'),
                        'message'=>'套票关联子票被下架或删除，系统自动下架该套票',
                    );
                    buildMess($stateMsg);
                }
            }
        }
        echo $res;
        break;
    // 设置套票景区上架
    case 'SetPackState':
        $id = $_POST['lid'];//数组或数字
        $state = abs($_POST['state']);
        $operid = isset($_SESSION['memberID'])? 
        $_SESSION['memberID']: exit('{"msg":"您还未登录或登录超时，请刷新页面后重新登录"}') ;
        $res = isEffectivePack($id,$GLOBALS['le'],true)? 
        $prod->SetSceneryState($id,$state,'分销商ID='.$operid):1001;
        echo $res;
        break;
    case 'SetProdStatus':
        //票类上下架
        $ids = rtrim($_POST['ids'],',');
        $status = abs($_POST['status']);
        $operid = $_SESSION['memberID'] ;
        echo json_encode($prod->SetTicketStatus($status,$ids,$operid));
        break;
    case 'EditNotifyPhonenum':
        $landid   = (int)$_POST['lastid'];
        $phonenum = $_POST['phonenum'];
        if(!ismobile($phonenum)){
            exit('不正确的手机号码');
        }
        $str = "UPDATE uu_land SET fax='{$phonenum}' WHERE id={$landid} LIMIT 1";
        $GLOBALS['le']->query($str);
        echo 'ok';
        break;
    case 'GetTickets':
        $ticket = new Ticket($GLOBALS['le']);
        $landid = abs($_GET['lid']);
        $status = 0;
        $priceFlag = isset($_GET['flag']) && $_GET['flag']=='all' ? 0 : 1;
        $output = $ticket->GetTicketByLimit($landid, $applydid, $status, $priceFlag,$soap);
        echo json_encode($output);
        break;
    // 根据景区获取供应商可销售门票
    case 'GetSaleTicket':
        $sales = $member->salePros($_REQUEST['lid']);
        $reqArr = array();
        // print_r($sales);
        foreach($sales as $k=>$v){
            if($v['sapply_did']!=$_REQUEST['aid']) continue;
            $tmp = array();
            $tmp['prodid'] = $v['pid'];
            $tmp['ticketTitle'] = $v['ttitle'];
            $tmp['marketPrice'] = $v['tprice'];
            $tmp['salePrice'] = 0;
            $tmp['setlPrice'] = 0;
            $tmp['validDays'] = $v['delaydays'];
            $tmp['landid'] = $_REQUEST['lid'];
            $tmp['status'] = $v['status'];
            $reqArr[] = $tmp;
        }
        echo json_encode($reqArr);
        break;
    case 'TerminalChk':
        // if(!isset($_SESSION['useTer'])||$_SESSION['useTer']!=1){
            // $sql="SELECT mobile_v_code FROM pft_member_extinfo WHERE fid={$_SESSION['memberID']} LIMIT 1";
            // $GLOBALS['le']->query($sql);
            // $GLOBALS['le']->fetch_assoc();
            // if(604800<(time()-strtotime($GLOBALS['le']->f('mobile_v_code')))){// 距上次验证过7天
                // exit('{"status":"fail","msg":"提示:您没有验证手机号"}');
            // }
            // $_SESSION['useTer'] = 1;
        // }
        // $time = $_REQUEST['chktime'];
        
        //软终端验证
        $salerid = safetxt($_POST['salerid']);
        $certnum = safetxt($_POST['certnum']);
        if(empty($salerid) || empty($certnum)) {
            break;
        }
        // echo "Terminal_Check_In($salerid, $certnum ,$time)";
        // exit;
        $operID = $_SESSION['memberID'];
        $res = $soap->Terminal_Check_In($salerid, $certnum ,$time, $operID);
//        if ($_SESSION['account']=='600888') {
//            echo '$soap->Terminal_Check_In('.$salerid .','. $certnum .' ,'.$time .','. $operID .')';
//            echo $res;
//        }

        if(ctype_digit($res)){
            if($res==105){
                exit('{"status":"fail","msg":"提示:不存在此凭证号！"}');
            } elseif($res==121){
                exit('{"status":"fail","msg":"此凭证号已被验证，不能重复验证！"}');
            } elseif($res==119){
                exit('{"status":"fail","msg":"提示:订单状态出错，请联系技术人员！"}');
            } elseif($res==133){
                exit('{"status":"fail","msg":"提示:游玩时间未到，今日无法验证！"}');
            } elseif($res==134){
                exit('{"status":"fail","msg":"提示:游玩时间已超过，今日无法验证！"}');
            } else{
                exit('{"status":"fail","msg":"提示:'.$SoapRequestChk[$res].'"}');
            }
        }
        $result=simplexml_load_string($res);
        //订单号，流水号UUino
        $ordernum  =$result->Rec->UUordernum;
        $uuino     =(string)$result->Rec->UUino;
        include("../class/OrderRecord.php");
        $order = new OrderRecord((string)$ordernum,$soap);
        $orderDetail = $order->info();
        $a_orderInfoOut = array(
            'UUordernum'  => (string)$orderDetail['mainOrder']->UUordernum,
            'uuino'       => $uuino,
            'UUordername' => (string)$orderDetail['mainOrder']->UUordername,
            'UUordertel'  => (string)$orderDetail['mainOrder']->UUordertel,
            'UUordertime' => (string)$orderDetail['mainOrder']->UUordertime,
            'UUbegintime' => (string)$orderDetail['mainOrder']->UUbegintime,
            'UUpmode'     => (string)$orderDetail['mainOrder']->UUpmode,
            'tickets'     => array(
                array(
                    'title' => (string)$orderDetail['mainOrder']->UUttitle,
                    'tnum'   => (int)$orderDetail['mainOrder']->UUtnum,
                )
            )

        );
        if(!empty($orderDetail['childOrder'])
            && is_array($orderDetail['childOrder'])) {
            foreach($orderDetail['childOrder'] as $child) {
                // var_export($child);
                $a_orderInfoOut['tickets'][] = array(
                    'title' => (string)$child->UUttitle,
                    'tnum'  => (int)$child->UUtnum
                );
            }
        }
        //员工操作，记录日志
        if($_SESSION['dtype']==6) {
            MemberAccount::StuffOptLog($_SESSION['memberID'], $_SESSION['sid'], "订单验证,订单号【{$ordernum}】");
        }
        $ao = array(
            'status'=>'ok',
            'msg'=>'验证成功',
            'body'=>$a_orderInfoOut,
        );
        echo json_encode($ao);
        break;
    case 'FindSalers':
        $sname = safetxt($_GET['sname']);
        $list = $mem->GetSalerList($sname);
        echo json_encode($list);
        break;
    case 'CountSale':
        //统计票类中销量
        $tid = intval($_GET['tid']);
        if($tid>0){
            $ticket = new Ticket($GLOBALS['le']);
            $c = $ticket->CountTicketSale($tid, $soap);
            $s = explode(',', $c);
            echo $s[1];
        }
        break;
    case 'ProdEvolute':
        if(!$_SESSION['memberID']) {
            exit('{"status":"fail","msg":"登录超时请重新登录"}');
        }
        //产品二手供应
        $pid = $_POST['pid'];
        $dtype = intval($_POST['dtype']);//0取消选择1更改选择或新增
        list($apply_did, $aids, $eid) = explode('|', $_POST['info']);


         //判断是否可以购买此供应商下的产品
//        $str="select pids from pft_product_sale_list where fid={$_SESSION['memberID']} and aid=$apply_did and status=0 limit 1";
//        $GLOBALS['le']->query($str);
//        $GLOBALS['le']->fetch_assoc();
//        $pids=$GLOBALS['le']->f('pids');
//        if ($pids!='A'){
//            $a_pids=explode(',',$pids);
//            if (!in_array($pid,$a_pids)) {
//                echo "<script>alert('您已无权购买此产品，配置失败！');</script>";
//                exit;
//            }
//        }

        $sql_update = "UPDATE pft_p_apply_evolute SET active=0 WHERE pid=$pid".
            " AND fid={$_SESSION['memberID']} AND active=1 LIMIT 1";
        $GLOBALS['le']->query($sql_update);
        if( !$dtype ) {
            //删除该产品下级分销商的供应数据
            $sql_hanler = "DELETE FROM pft_p_apply_evolute WHERE sid={$_SESSION['memberID']} AND pid=$pid";
            $GLOBALS['le']->query($sql_hanler);
            echo '{"status":"ok","msg":"操作成功！"}';
            exit;
        }
        if( ! $eid ) {
            $sql_hanler = "INSERT INTO pft_p_apply_evolute(fid,sid,sourceid,pid,".
                "lvl,status,rectime,aids,active) VALUES({$_SESSION['memberID']}, $apply_did".
                ",$apply_did,$pid,1,0,now(),$apply_did,1)";
        }
        else {
            //更新该记录为活动状态
            $GLOBALS['le']->query("UPDATE pft_p_apply_evolute SET active=1 WHERE id=$eid LIMIT 1");
            //删除该产品下级分销商的供应数据
            $sql_hanler = "DELETE FROM pft_p_apply_evolute WHERE sid={$_SESSION['memberID']} AND pid=$pid";
        }
        $GLOBALS['le']->query($sql_hanler);
        echo '{"status":"ok","msg":"操作成功！"}';
        break;
    case 'CheckOrderPay':
        $orderid = trim($_GET['orderid']);
        include("../class/OrderRecord.php");
        $order = new OrderRecord($orderid, $soap);
        $orderDetail = $order->info();
        if($orderDetail['mainOrder']->UUpmode==1
            &&$orderDetail['mainOrder']->UUpaystatus!=1) {
            exit('0');
        } else {
            echo('1');
        }
        break;
    case 'PriceRemove':
        $prcid = abs($_GET['prcid']);
        $pobj = new Price($pid);
        echo $pobj->RemoveSPrice($prcid);
        break;
    default:
        break;
}


//include("class/OrderRecord.php");
//$or=new OrderRecord($ordernum,$s);
//$orderInfo=$or->info();
